From 02cfcae8bd9192449327c1634600ca918e50028c Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Tue, 28 Nov 2017 15:27:58 -0700 Subject: [PATCH] add a test of utf8 filename handlig. --- build_and_test | 1 + test_encoding_utf8 | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100755 test_encoding_utf8 diff --git a/build_and_test b/build_and_test index 2c37da12b..d0ace4d00 100755 --- a/build_and_test +++ b/build_and_test @@ -33,6 +33,7 @@ make gpsbabel.html make check # test for mangled encoding of command line arguments ./test_encoding +./test_encoding_utf8 #make torture rm -f vg.log ./vtesto -l -j vg.log diff --git a/test_encoding_utf8 b/test_encoding_utf8 new file mode 100755 index 000000000..8abe07a66 --- /dev/null +++ b/test_encoding_utf8 @@ -0,0 +1,84 @@ +#!/bin/bash +# this file should be encoded in utf8 + +BASEPATH=`dirname $0` +PNAME=${PNAME:-${BASEPATH}/gpsbabel} +REFERENCE=${BASEPATH}/reference + +TMPDIR=${GBTEMP:-/tmp}/gpsbabel.$$ +mkdir -p $TMPDIR +trap "rm -fr $TMPDIR" 0 1 2 3 15 + +errorcount=0 + +cmap=$(locale charmap) +if [ "${cmap}" == "UTF-8" ] ; then + +echo "Running utf-8 file name encoding test" +filenamebase=test_encoding_fileαβγ + +# test input file name mangling with gpsbabel::File + echo "testing input file name with gpsbabel::File" + rm -f ${TMPDIR}/test_encoding_file* + cp ${REFERENCE}/bounds-test.gpx ${TMPDIR}/${filenamebase}.gpx + ${PNAME} -i gpx -f ${TMPDIR}/${filenamebase}.gpx -o kml -F ${TMPDIR}/test_encoding_fileo.kml || { + echo "ERROR: The input file name was mangled." + errorcount=`expr $errorcount + 1` + } + +# test output file name mangling with gpsbabel::File + echo "testing output file name with gpsbabel::File" + rm -f ${TMPDIR}/test_encoding_file* + ${PNAME} -i gpx -f ${REFERENCE}/bounds-test.gpx -o kml -F ${TMPDIR}/${filenamebase}.kml + count=$(ls -1 -l ${TMPDIR}/${filenamebase}.kml 2>/dev/null | wc -l) + if [ $count -lt 1 ]; then + echo "ERROR: The output file name was mangled." + errorcount=`expr $errorcount + 1` + fi + +# test input file name mangling with gbfile stdapi + echo "testing input file name with gbfile stdapi" + rm -f ${TMPDIR}/test_encoding_file* + cp ${REFERENCE}/unicsv_subsec.csv ${TMPDIR}/${filenamebase}.csv + ${PNAME} -i unicsv -f ${TMPDIR}/${filenamebase}.csv -o kml -F ${TMPDIR}/test_encoding_fileo.kml || { + echo "ERROR: The input file name was mangled." + errorcount=`expr $errorcount + 1` + } + +# test output file name mangling with gbfile stdapi + echo "testing output file name with gbfile stdapi" + rm -f ${TMPDIR}/test_encoding_file* + ${PNAME} -i gpx -f ${REFERENCE}/bounds-test.gpx -o unicsv -F ${TMPDIR}/${filenamebase}.csv + count=$(ls -1 -l ${TMPDIR}/${filenamebase}.csv 2>/dev/null | wc -l) + if [ $count -lt 1 ]; then + echo "ERROR: The output file name was mangled." + errorcount=`expr $errorcount + 1` + fi + +# test input file name mangling with gbfile gzapi + echo "testing input file name with gbfile gzapi" + rm -f ${TMPDIR}/test_encoding_file* + cp ${REFERENCE}/sample.gtm.gz ${TMPDIR}/${filenamebase}.gtm.gz + ${PNAME} -i gtm -f ${TMPDIR}/${filenamebase}.gtm.gz -o kml -F ${TMPDIR}/test_encoding_fileo.kml || { + echo "ERROR: The input file name was mangled." + errorcount=`expr $errorcount + 1` + } + +# test output file name mangling with gbfile gzapi + echo "testing output file name with gbfile gzapi" + rm -f ${TMPDIR}/test_encoding_file* + ${PNAME} -i gpx -f ${REFERENCE}/bounds-test.gpx -o gtm -F ${TMPDIR}/${filenamebase}.gtm.gz + count=$(ls -1 -l ${TMPDIR}/${filenamebase}.gtm.gz 2>/dev/null | wc -l) + if [ $count -lt 1 ]; then + echo "ERROR: The output file name was mangled." + errorcount=`expr $errorcount + 1` + fi + +# TODO: add tests to cover formats that use other open methods. +# for example shape files. + +else + echo "$0 cannot run without the UTF-8 charmap." +fi + +exit $errorcount -- 2.30.2